﻿using System.Diagnostics;

namespace ZeBobo5.LibraryHelper.Core
{
    public class NullableHelper<T> where T : struct
    {
        [DebuggerNonUserCode]
        public static T GetValue(T? nullable, T defaultValue)
        {
            if (nullable.HasValue)
            {
                return nullable.Value;
            }
            return defaultValue;
        }

        [DebuggerNonUserCode]
        public static string GetStringValue(T? nullable)
        {
            return GetStringValue(nullable, "");
        }

        [DebuggerNonUserCode]
        public static string GetStringValue(T? nullable, string defaultValue)
        {
            if (nullable.HasValue)
            {
                return nullable.Value.ToString();
            }
            return defaultValue;
        }
    }
}